﻿using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;

namespace MVCGalloSoftMV5.Models
{
    [Table ("Estado")]
    public class Estado
    {
        [Key]
        public int EstadoId { get; set; }

        [Display(Name = "WBS")]
        [StringLength(50)]
        [Required(ErrorMessage = "Campo WBS es requerido.")]
        public string wbs { get; set; }

        [Column("Descripcion")]
        [Display(Name="Estado")]
        [StringLength(100)]
        [Required(ErrorMessage = "Campo Estado es requerido.")]
        public string Descripcion { get; set; }

        public virtual ICollection<Municipio> Municipios { get; set; }
        [NotMapped]
        [Display(Name = "No. Municipios")]
        public int No_Municipios {
            get {
                return Municipios.Count;
            }
        }

        [NotMapped]
        [Display(Name = "No. Proyectos")]
        public int No_Proyectos
        {
            get
            {
                return (from m in Municipios select m.No_Proyectos).Sum();
            }
        }


    }
}
